import selectors
import threading
import _threading_local


class EventLoop:
    def __init__(self):
        self._is_running = False
        self._thread = threading.current_thread()
        self._selector = selectors.DefaultSelector()

        local = threading.local()
        assert(local.__dict__.get("event_loop") == None)
        local.event_loop = self

    def run(self):
        assert(not self._is_running)
        assert(self._thread is threading.current_thread())
